<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include_once("../config.inc.php");

$arrWeb = split(",", $_data["AllWeb"]);
$GameDate = (empty($_data["GameDate"]))?date("Y-m-d"):$_data["GameDate"];
$GameTime1 = (empty($_data["GameTime1"]))?"00:00:00":$_data["GameTime1"];
$GameTime2 = (empty($_data["GameTime2"]))?"24:00:00":$_data["GameTime2"];
if(!get_magic_quotes_gpc()){
	$GameDate = addslashes($GameDate);
	$GameTime1 = addslashes($GameTime1);
	$GameTime2 = addslashes($GameTime2);
}
if($GameTime1 > $GameTime2){
	$strTmp = $GameTime1;
	$GameTime1 = $GameTime2;
	$GameTime2 = $strTmp;
}

$strTmp1 = "<tr>
	<td class='web-name'>{No}</td>
	<td class='web-name'>{Web}</td>
	<td class='web-td'><!--WagerNo//-->0</td>
	<td class='web-td'><!--WagerMoney//-->0</td>
	<td class='web-td'><!--StockResult//-->0</td>
</tr>";

$intTotalN = 0;
$intTotalM = 0;
$flTotalR = 0;
$arrDB = array();
$strCon = "";
$intNo = 0;
foreach($arrWeb as $strDN){
	//$arrDN = split("@", $strDN);
	//$strDomain = $arrDN[0];
	$strDomain = $strDN;
	//$strDName = $arrDN[1];
	include("/home/share/www/".$strDomain."/secure/db.inc.php");

	$strTmp2 = $strTmp1;
	$strTmp2 = str_replace("{Web}", $strDomain." -- {".$strDomain."} &nbsp;(".$_blDBHostM.")", $strTmp2);
	$intNo++;
	$strTmp2 = str_replace("{No}", $intNo, $strTmp2);

	$strSQL = "select COUNT(*) as WagerNo, SUM(a.MemStake) as WagerMoney, SUM(a.DirectorRateResult) as DirectorResult from `bet_BetList` a, `bet_BetListContent` b where a.PayupDate = '".$GameDate."' and a.isPayOff = 0 and a.ID = b.ID and (b.BetTime between '".$GameTime1."' and '".$GameTime2."')";
	//print $strSQL."<br>\n";
	$RS = @PMA_mysql_query($strSQL, $$_Conn);
	while($Rows = PMA_mysql_fetch_object($RS)){
		$strTmp2 = str_replace("<!--WagerNo//-->0", $Rows -> WagerNo, $strTmp2);
		$strTmp2 = str_replace("<!--WagerMoney//-->0", $Rows -> WagerMoney, $strTmp2);
		$strTmp2 = str_replace("<!--StockResult//-->0", sprintf("%0.1f", $Rows -> DirectorResult), $strTmp2);
		$intTotalN += $Rows -> WagerNo;
		$intTotalM += $Rows -> WagerMoney;
		$flTotalR += $Rows -> DirectorResult;
	}
	$strCon .= $strTmp2;
	@mysql_free_result($RS);
	@mysql_close($$_Conn);
}

$strTmp2 = str_replace("{Web}", "Sum", $strTmp1);
$strTmp2 = str_replace("{No}", "", $strTmp2);
$strTmp2 = str_replace("<!--WagerNo//-->0", $intTotalN, $strTmp2);
$strTmp2 = str_replace("<!--WagerMoney//-->0", $intTotalM, $strTmp2);
$strTmp2 = str_replace("<!--StockResult//-->0", sprintf("%0.1f", $flTotalR), $strTmp2);
$strCon .= $strTmp2;
?><!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> Report </title>
<style>
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	font-size: 12px
	font-family: Arial, Helvetica, Verdana, Geneva,  sans-serif;
	background-color: #EFFFDF;
}
td {
	font-size: 12px
	font-family: Arial, Helvetica, Verdana, Geneva,  sans-serif;
	background-color: #FFFFFF;
	text-align: center;
}
.showTable {
	background-color: #9DBAD8;
	border: 1px solid #056FD8;
}
.web-td {
	text-align: right;
	padding-right: 2px;
}
.web-name {
	text-align: left;
	padding-left: 2px;
}
//-->
</style>
</head>

<body>
<table  border="0" cellspacing="1" cellpadding="0" class="showTable">
<tr>
	<td width="50">序號</td>
	<td width="150">網站</td>
	<td width="120">注單數</td>
	<td width="120">總金額</td>
	<td width="120">總監結果</td>
</tr>
<?php print $strCon;?>
</table>
報表日期：<?php print $GameDate;?><br />
現在時間：<?php print date("Y-m-d H:i:s");?><br /><br />
</body>
</html>